0 CLS:CLEAR400:GOTO2000
5 V=VARPTR(D(0))+97:U=V+2251:RETURN
10 FORI=24TO480STEP32:PRINT@I,BL$;:NEXTI:RETURN
700 INPUT"ENTER DUNGEON NAME";A$:PRINT"PRESS PLAY":LOAD*D,LEFT$(A$,8):SO=1:RETURN
900 DATA9,1,-1,1,-2,9,1,1,2,1,9,-1,1,-1,2,9,-1,-1,-2,-1,0,13,2,1,1
901 DATA1,0,2,0,0,1,1,1,2,1,3,1,0,2,3,2,0,0,1,0,1,1,1,2,2,2,3,2,3,1,0,0,1,0,3,0,0,1,1,1,2,1,3,1,1,2,3,2
904 DATA1,0,2,0,0,1,1,1,2,1,3,1,1,2,2,2,0,0,3,0,1,1,2,1,1,2,2,2,0,0,0,0,0,0,1,1,2,1,3,0,0,0,0,0,0,0,0,0
905 DATA0,0,3,0,1,1,2,1,0,2,3,2,0,0,0,0,FLAME,DUST,MOLD,PIT,"",SPEAR,NEEDLE,XBOW,CAVEIN,CEILING
2000 DIMD(500),I,J,C,Z,P(4),S(4),ZA(3),ZD(5),TX(3,1),TY(3,1),TM(5),RF(3),RN(3),A(6,7),B(6,7),G
2001 PRINT@138,"DUNJONQUEST":PRINT@70,"THE TEMPLE OF APSHAI":PRINT@297,"COPYRIGHT 1979":PRINT@357,"AUTOMATED  SIMULATIONS"
2002 FORI=0TO30:PRINT@I,"ż";:PRINT@I+480,"ż";:NEXTI:FORI=31TO480STEP32:PRINT@I,"żż";:NEXTI:POKE16895,191
2210 DIMQ,KM,Q2,K,X,Y,L,M,N,V,A,B,NN,NS,I1,LR,KR,YA,YB,NB,NO,NT,D1,D2,MT,ML,MN,MD,MS,MH,M1,IH,NP,XP,W
2211 DIMYP,IB,TR,XR,YR,U,X1,X2,XA,XB,Y1,Y2,TN,TV,TP,TG,TW,TS,UL,IA,UA,UP,US,UD,UC,UR,UI,UW,UV,BL$,SE,PC,YM,XM,XL,YL
2212 DIMIN,L1,L2,L3,L4,LM,LX,II,IK,NY,NX,KF,LE,IC,C$,IJ,PH,TA,LL,V1,V2,V3,V4,W1,W2,W3,W4,MO,A$,EX,MM,PB,PA,PS,AA,AS,WM,WT
2220 DIMWC,SM,IR,MQ,MW,MA,MP,MR,MF,LS,O$,X0,Y0,HI,P,R,AK,Q1,PW,JJ,UX,S,LY,UY,SP,IM,KC,T$(9),SO
2230 Q=RND(-(PEEK(9)*256+PEEK(10))):Q=60:KM=0:Q1=12:Q2=20
2240 FORI=0TO3:READC:FORJ=0TO1:READTX(I,J),TY(I,J):NEXTJ:NEXTI:FORI=1TO5:READTM(I):NEXTI:C=.5:Z=.66
2242 FORI=0TO6:FORJ=0TO7:READA(I,J),B(I,J):NEXTJ:NEXTI
2250 GOSUB5:NO=V:NT=4*Q+V:D1=8*Q+V:D2=12*Q+V:MT=16*Q+V:MN=MT+Q:NP=MN+Q:XP=NP+Q:YP=XP+Q:TR=YP+Q:XR=TR+Q:YR=XR+Q:GOSUB2390
2260 X1=YR+Q:X2=X1+2*Q:Y1=X2+2*Q:Y2=Y1+2*Q:TN=Y2+2*Q:TV=TN+10:TP=TV+10:TG=TP+10:TW=TG+10:TS=TW+Q2:UL=TS+Q2:UA=UL+Q1
2261 UP=UA+Q1:US=UP+Q1:UD=US+Q1:UC=UD+Q1:UR=UC+Q1:UI=UR+Q1:UW=UI+Q1:UV=UW+Q1:BL$="        ":FORI=1TO8:BL$=BL$+CHR$(8):NEXTI
2270 ZD(0)=3:ZA(1)=0:ZD(1)=0:ZA(2)=3:ZD(2)=3:ZA(3)=-6:ZD(3)=-2:ZD(4)=5:ZD(5)=5:SE=100
2290 FORI=0TO9:READT$(I):NEXTI:CLS:GOSUB700:GOTO3260
2300 PC=PC-1:POKEU+24,PEEK(U+24)-1:POKEV-92,PEEK(V-92)-1:RETURN
2310 B=W1-W2-5:IFYM>BTHENYM=B:GOTO2320
2311 IFYM<5THENYM=5
2320 A=V2-V1-5:IFXM>ATHENXM=A:RETURN
2321 IFXM<5THENXM=5
2330 RETURN
2340 PRINT@472,RIGHT$(STR$(J)+"ARROWS",8);:RETURN
2350 POKE49151,64:FORI=1TO40:NEXTI:SOUND1,2:RETURN
2360 GOSUB2800:IFL=0GOTO2360
2361 J=ASC(C$)-48:IFJ<0ORJ>9GOTO2360
2362 RETURN
2370 PRINT@248,BL$"AR:"PEEK(U+13);:RETURN
2380 PRINT@280,BL$"MA:"PEEK(U+14);:RETURN
2390 FORI=1TO60:POKEV-I,0:NEXTI:RETURN
2400 FORI=0TO3:RN(I)=0:IFRF(I)>0THENPOKENT+KR+I*Q,3:POKEV+KR-61,0:RN(I)=1:RF(I)=0
2410 NEXTI:I=KF+1:IFI>3THENI=I-4
2420 IFRN(KF-1)>0THENRF(I)=1
2430 RETURN
2440 POKEN,PEEK(IA+NN):NN=NN+1:RETURN
2450 L1=B:L2=B+L-1:IFL1<0THENL1=0:IFL2<0THENRETURN
2460 IFL2>47THENL2=47:IFL1>47THENRETURN
2470 L3=INT((L1+3)/3):L4=INT((L2-3)/3):LM=3*L4+3:LX=3*L3-1:IFLM<L1THENLM=L1
2480 IFLX>L2THENLX=L2
2490 FORII=ATOA+1:IFII<0ORII>47THENRETURN
2500 I=2*II:FORIK=L1TOLX:GOSUB2740:NEXTIK:FORIK=LMTOL2:GOSUB2740:NEXTIK
2510 IFL4>=L3THENFORNY=L3TOL4:SET(II,NY*2,4):SET(II,NY*2+1,4):NEXTNY
2520 NEXTII:RETURN
2530 L1=B:L2=B+L-1:IFL1<0THENL1=0:IFL2<0THENRETURN
2540 IFL2>47THENL2=47:IFL1>47THENRETURN
2550 FORI=0TOI1:NX=2*A+I:IFNX<0ORNX>96THENRETURN
2560 FORJ=L1+CTOL2-C:RESET(C*NX,J*Z):NEXTJ:NEXTI:RETURN
2570 L1=A:L2=(C*(2*A+L-1))-C:IFL1<0THENL1=0:IFL2<0THENRETURN
2580 IFL2>47THENL2=47:IFL1>47THENRETURN
2590 FORI=0TOI1:NY=INT(Z*(B+I)):IFNY<0ORNY>31THENRETURN
2600 FORJ=L1TOL2:SET(J,NY,4):NEXTJ:NEXTI:RETURN
2610 L1=A:L2=(C*(2*A+L-1))-C:IFL1<0THENL1=0:IFL2<0THENRETURN
2620 IFL2>47THENL2=47:IFL1>47THENRETURN
2630 FORI=0TOI1:NY=INT(Z*B+I):IFNY<0ORNY>31THENRETURN
2640 FORJ=L1TOL2:RESET(J,NY):NEXTJ:NEXTI:RETURN
2650 I1=1
2660 A=2*(XA-XB):B=YB-YA:I=INT(A*C):IK=INT(B*Z):ONKFGOTO2670,2680,2670,2680
2670 IFI-1<0ORI+1>63ORIK-1<0ORIK+1>31THENRETURN
2671 ONI1GOTO2672:RESET(I-1,IK):RESET(I+1,IK):RESET(I,IK+SGN(KF-2)):RETURN
2672 SET(I-1,IK,4):SET(I+1,IK,4):SET(I,IK+SGN(KF-2),4):RETURN
2680 IFI-1<0ORI+1>63ORIK-1<0ORIK+1>31THENRETURN
2681 ONI1GOTO2682:RESET(I,IK-1):RESET(I,IK+1):RESET(I+SGN(3-KF),IK):RETURN
2682 SET(I,IK-1,4):SET(I,IK+1,4):SET(I+SGN(3-KF),IK,4):RETURN
2690 I1=2:GOTO2660
2700 I1=1
2710 A=2*(XM-XB+V1)-1:B=YB-YM-W2:I=A*C:IK=(B-1)*Z:ONI1GOTO2731,2735
2720 IFNB=0THENRETURN
2730 I1=2:GOTO2710
2731 IFI<0ORI+3>47ORIK<0ORIK+3>31THENRETURN
2732 FORJ=0TO7:SET(I+A(W,J),IK+B(W,J),G):NEXTJ:RETURN
2735 IFI<0ORI+3>47ORIK<0ORIK+3>31THENRETURN
2736 FORJ=0TO7:SET(I+A(W,J),IK+B(W,J),4):RESET(I+A(W,J),IK+B(W,J)):NEXTJ:RETURN
2740 IFI<0ORI>94ORIK<0ORIK>47THENRETURN
2741 SET(C*I,IK*Z,4):RETURN
2750 IFI<0ORI>94ORIK<0ORIK>47THENRETURN
2751 FORJ=0TO1:RESET(C*(I+J),IK*Z):NEXTJ:RETURN
2760 IFK=0THENSET(C*I,(B-J)*Z,4):SET(C*I,(B+J)*Z,4):RETURN
2761 RESET(C*I,(B-J)*Z):RESET(C*I,(B+J)*Z)
2770 RETURN
2780 FORL=0TO2:FORK=0TO1:I=A+1:J=1:GOSUB2760:I=A-1:GOSUB2760:I=A+2:J=0:GOSUB2760:I=A-2:GOSUB2760
2790 I=A+2:J=2:GOSUB2760:I=A-2:GOSUB2760:I=A+4:J=0:GOSUB2760:I=A-4:GOSUB2760:NEXTK:NEXTL:RETURN
2800 LE=SE/(NB+1):FORIC=1TOLE
2810 C$=INKEY$:IFLEN(C$)>0THENL=1:RETURN
2820 NEXTIC:L=0:RETURN
2830 II=2*(XL-XB+V1):IJ=YB-YL-W2:I=INT(II*C):IK=INT(IJ*Z):IFI<2ORI>45ORIK<2ORIK>29THENRETURN
2831 IFK=0THENSET(I+TX(KF-1,0),IK+TY(KF-1,0),4):FORL=1TO4:NEXTL:SET(I+TX(KF-1,1),IK+TY(KF-1,1),4):FORL=1TO4:NEXTL:RETURN
2832 RESET(I+TX(KF-1,0),IK+TY(KF-1,0)):FORL=1TO4:NEXTL:RESET(I+TX(KF-1,1),IK+TY(KF-1,1)):FORL=1TO4:NEXTL:RETURN
2850 PH=PEEK(U+24):TA=INT(TA-(ABS(M)/MM*(100/PH+5-5*PC/PH)*(1+WC/WT*3)/2)+11):IFTA>100THENTA=100
2860 PRINT@88,BL$"FT:"TA;:RETURN
2870 Y=YB-PEEK(YP+KR)-W2:X=PEEK(XP+KR)+V1-XB:FORL=1TO15:I=2*X:IK=Y:GOSUB2740:GOSUB2750:NEXTL:RETURN
2880 IFPEEK(TR+KR)=0THENRETURN
2890 I=2*(V1+PEEK(XR+KR)-XB):B=YB-W2-PEEK(YR+KR):FORIK=B-1TOB:IFPEEK(TR+KR)>0THENGOSUB2740:GOTO2900
2891 GOSUB2750
2900 NEXTIK:RETURN
2910 N=PEEK(NP+KR):L=0:IFNB>0ORN=0ORABS(XL-PEEK(XP+KR))>3ORABS(YL-PEEK(YP+KR))>3ORRND(100)>PEEK(TP+N)THENRETURN
2920 PRINT@312,BL$LEFT$(T$(PEEK(TG+N)),8);:GOSUB2350:GOSUB2350
2921 IFPEEK(TN+N)>0THENI=PEEK(TN+N):NB=1:GOSUB3240:XM=PEEK(XP+KR):YM=PEEK(YP+KR):PRINT@312,A$;:GOTO2940
2930 IFPEEK(TV+N)>0THENML=PEEK(TV+N):L=1:MD=2*ML
2940 POKENP+KR,0:RETURN
2950 LL=KR:GOTO2970
2960 LL=LR
2970 V3=PEEK(X1+LL)+128*PEEK(X1+Q+LL):V4=PEEK(X2+LL)+128*PEEK(X2+Q+LL):W3=PEEK(Y1+LL)+128*PEEK(Y1+Q+LL)
2971 W4=PEEK(Y2+LL)+128*PEEK(Y2+Q+LL):IFLL<>KRTHENRETURN
2980 V1=V3:V2=V4:W1=W3:W2=W4:RETURN
2981 K=0:MO=V+2121:FORLL=1TOMQ:L=PEEK(K+MO):K=K+L+1:NEXTLL:K=K-L-1:A$="":FORLL=1TOL:A$=A$+CHR$(PEEK(K+MO+LL)):NEXTLL
2982 A$=LEFT$(A$,8):W=0:G=4:IFA$="CENTIPED"ORA$="CRRN CRW"THENW=1:G=1:RETURN
2983 IFA$="GNT RAT"ORA$="GIANT RA"THENW=2:A$="GNT RAT":G=8:RETURN
2984 IFA$="GIANT AN"THENW=2:A$="GNT ANT":G=3:RETURN
2985 IFA$="SKELETON"ORA$="ZOMBIE"ORA$="WIGHT"ORA$="GHOUL"THENW=4:G=5:RETURN
2986 IFA$="MOSQUITO"ORA$="ANT MAN"ORA$="ANTMAN"THENW=6:G=3:RETURN
2987 IFA$="GIANT AM"THENW=3:A$="G.AMOEBA":G=7:RETURN
2988 IFA$="GIANT TI"THENW=6:A$="GNT TICK":G=1:RETURN
2989 IFA$="GIANT WA"THENW=6:A$="GNT WASP":G=2:RETURN
2992 IFA$="GNT TERM"ORA$="SWAMP RA"THENW=2:G=1:RETURN
2993 IFA$="JELLY"ORA$="GNT LEEC"ORA$="ROCKFALL"THENW=3:G=2:RETURN
2996 IFA$="VAMPIRE "THENW=5:A$="VAMP BAT":G=7:RETURN
2997 IFA$="SKELETAL"THENW=5:A$="SKEL BAT":G=5:RETURN
2998 IFA$="GIANT MA"THENW=6:A$="G.MANTIS":G=1
2999 RETURN
3000 XA=PEEK(V+2236):YA=PEEK(V+2237):KF=PEEK(V+2238):PW=PEEK(V+2235):EX=D(498)
3001 FORI=61TO80:POKEV-I,0:NEXTI
3010 MM=4:PH=PEEK(U+24):PC=PH:PB=PEEK(U+18):PA=PEEK(U+19):PS=PEEK(U):AA=PEEK(U+8):TA=100
3011 AS=PEEK(U+23)/10:WM=PEEK(U+7):SE=PEEK(U+9):WT=AS*AS*100:WC=PEEK(U+12):SM=PEEK(U+10):RETURN
3020 IFPEEK(V+LR-61)=1THENRETURN
3021 GOSUB2960:A=V4-XB-2:IFV3-XB>-1ANDV4-XB<49ANDYB-W3>-1ANDYB-W4<49THENPOKEV+LR-61,1
3030 FORK=1TO3STEP2:NN=LR+K*Q:B=YB-W3:IFNS=KGOTO3050
3031 I1=3:L=W3-W4:IFPEEK(D2+NN)-PEEK(D1+NN)+4=LGOTO3050
3032 GOSUB2450
3040 I1=5-2*PEEK(NT+NN):IFI1>=0ANDI1<5THENB=YB-W4-PEEK(D2+NN):L=PEEK(D2+NN)-PEEK(D1+NN):GOSUB2530
3050 A=V3-XB:NEXTK
3060 B=YB-W3:FORK=0TO2STEP2:NN=LR+K*Q:IFNS=KGOTO3070
3061 I1=1:A=V3-XB:L=2*(V4-V3):IFPEEK(D2+NN)-PEEK(D1+NN)+4=L/2GOTO3070
3062 GOSUB2570:I1=2-PEEK(NT+NN):IFI1>=0ANDI1<2THENA=V3-XB+PEEK(D1+NN):L=2*(PEEK(D2+NN)-PEEK(D1+NN)):GOSUB2610
3070 B=YB-W4-2:NEXTK:RETURN
3080 LR=KR:GOSUB2950:CLS0:GOSUB10:IFSO=1THENSO=0:GOTO3082
3081 IFPEEK(V+KR-61)=1GOTO3120
3082 GOSUB2390
3090 XB=V1:YB=W1:IFPEEK(NT+LR+3*Q)=1THENXB=XB-(48-V2+V1)/2:IFPEEK(NT+LR+Q)=1THENXB=XB+(V1-XB)/2
3100 IFPEEK(NT+LR)=1THENYB=YB+48-W1+W2:IFPEEK(NT+LR+2*Q)=1THENYB=YB-(YB-W1)/2
3110 PRINT@312,BL$;:XL=XA-V1:YL=YA-W2:IFPEEK(MT+KR)>0ANDPEEK(MN+KR)>0THENGOSUB3180:NB=1:GOTO3120
3111 GOSUB3210
3120 PRINT@24,"RM:"KR;:PRINT@56,"WD:"INT(100*PC/PH+C);:PRINT@88,"FT:"TA;
3121 PRINT@120,"WT:"WC;:PRINT@312,LEFT$(A$,8);:PRINT@248,"AR:"PEEK(U+13);
3122 PRINT@280,"MA:"PEEK(U+14);:PRINT@376,"SLAIN:";:PRINT@408,KC;
3130 IFNB>0THENGOSUB2700
3140 NS=5:IFIB=3GOTO3170
3150 FORIR=0TO3:I=KR+IR*Q:IFPEEK(NT+I)=1ANDPEEK(NO+I)>0THENLR=PEEK(NO+I):GOSUB3020
3160 NEXTIR
3170 LR=KR:GOSUB3020:GOSUB2650:GOSUB2880:RETURN
3180 MQ=PEEK(MT+KR):MW=0:ML=PEEK(UL+MQ):MA=PEEK(UA+MQ):MP=PEEK(UP+MQ):MS=PEEK(UV+MQ):MD=PEEK(UD+MQ):MH=PEEK(UC+MQ):MR=0
3181 GOSUB2981:IH=0
3190 XM=RND(V2-V1-8)+4:YM=RND(W1-W2-8)+4
3200 MF=RND(4):RETURN
3210 L=RND(100):IFL>PWTHENNB=0:A$="":RETURN
3220 L=RND(100):LS=0:NB=1:FORI=1TOQ1:LS=LS+PEEK(UW+I):IFL<=LSGOTO3240
3230 NEXTI
3240 POKEMT+KR,I:POKEMN+KR,1:MQ=I:ML=PEEK(UL+I):MA=PEEK(UA+I):MP=PEEK(UP+I):MS=PEEK(UV+I):MD=PEEK(UD+I):MH=PEEK(UC+I)
3241 GOSUB2981:IH=0:GOSUB3190:RETURN
3250 L=RND(100):IFL<PW/6GOTO3220
3251 RETURN
3260 KR=1:O$="RLATPFMGEV!HQSYDO":GOSUB3000
3270 GOSUB3080:S(1)=W1-W2:S(2)=V2-V1:S(3)=0:S(4)=0
3280 P(1)=XA-V1:P(2)=YA-W2:P(3)=P(1):P(4)=P(2):P(0)=P(2)
3290 X0=XL:Y0=YL:IA=0:GOSUB2800:M=0:PRINT@152,BL$;:PRINT@184,BL$;:PRINT@216,BL$;:IFL=0GOTO4190
3300 IA=0:IFASC(C$)>47ANDASC(C$)<58GOTO3320
3301 FORI=1TO17:IFC$=MID$(O$,I,1)THEN3305
3302 GOTO3310
3305 ONIGOTO3550,3570,3610,3610,3610,3610,3610,3900,3880,3590,4070,4090,4140,4160,4120,4040,3780
3310 NEXTI:GOTO3290
3320 IFTA<1GOTO3610
3321 M=ASC(C$)-48
3330 M1=M:N=PEEK(NP+KR):IB=0:ONKFGOTO3340,3380,3360,3400
3340 IFYA+M>W1-3THENM=W1-3-YA:IB=1
3350 GOTO3430
3360 M=-M:M1=M:IFYA+M<W2+4THENM=W2+4-YA:IB=1
3370 GOTO3430
3380 IFXA+M>V2-3THENM=V2-3-XA:IB=1
3390 GOTO3430
3400 M=-M:M1=M:IFXA+M<V1+4THENM=V1+4-XA:IB=1
3410 GOTO3430
3420 IFNB>0GOTO4190
3421 GOTO4250
3430 IFIB=0GOTO3510
3431 XL=XA-V1:YL=YA-W2:IFPEEK(NT+KR+KF*Q-Q)<>1GOTO3510
3440 L=KR+KF*Q-Q:IFP(KF)>PEEK(D1+L)ANDP(KF)<PEEK(D2+L)THEN3445
3441 GOTO3450
3445 GOSUB2720:GOSUB2400:NB=0:IN=0:KR=PEEK(NO+L):GOSUB2950:IB=2:M=ABS(M)+4:IFKR=0GOTO4500
3450 IFIB=1GOTO3510
3460 IFV1-XB>-1ANDV2-XB<49ANDYB-W1>-1ANDYB-W2<49THENIB=3:S(1)=W1-W2:S(2)=V2-V1:M=M1:GOTO3510
3470 IFKF=1THENYA=W2+4:GOTO3270
3480 IFKF=3THENYA=W1-4:GOTO3270
3490 IFKF=2THENXA=V1+4:GOTO3270
3491 XA=V2-4:GOTO3270
3510 GOSUB2690:GOSUB2880:IFKF=1ORKF=3THENYA=YA+M:GOTO3520
3511 XA=XA+M
3520 IFPEEK(V-86)>0THENM=M/2
3530 GOSUB2650:P(1)=XA-V1:P(3)=P(1):P(2)=YA-W2:P(4)=P(2):P(0)=P(2):IFIB=3THENLR=KR:GOSUB3110:IB=0:GOTO3290
3540 XL=XA-V1:YL=YA-W2:GOSUB2910:IFL>0THENGOSUB2850:GOTO4250
3541 GOTO4190
3550 GOSUB2690:KF=KF+1:IFKF>4THENKF=1
3560 GOSUB2650:GOTO3290
3570 GOSUB2690:KF=KF-1:IFKF<1THENKF=4
3580 GOSUB2650:GOTO3290
3590 GOSUB2690:KF=KF-2:IFKF<1THENKF=KF+4
3600 GOSUB2650:GOTO3290
3610 IFTA<1THENPRINT@184,BL$"TIRED!";:GOTO4190
3611 IA=I-2:IN=0:KM=0:ONIAGOTO3620,3620,3620,3690,3680
3620 HI=0:IFABS(XL-XM)>5ORABS(YL-YM)>5THENPRINT@184,"TOO FAR";:GOTO4190
3630 M=TM(IA):K=0:GOSUB2830:P=PB-(PEEK(U+22)-9)/3*EXP(-2*PC/PH)+ML/3-ZA(IA):R=RND(20)
3631 IFR<PTHENPRINT@184,"SWISH!";:GOTO4180
3640 AK=AS*(R-P+1):PRINT@184,"CRUNCH!";:SOUND200,1:IFAK>WMTHENAK=WM
3650 IFAK<MHTHENAK=MH
3660 IFPEEK(US+MQ)<>2OR(PEEK(U+10)>0ANDIA<3)ORIA=4THENMP=MP-AK+MH:IN=0
3670 GOTO4180
3680 I1=5:KM=5:IFPEEK(U+14)<=0GOTO4190
3681 POKEU+14,PEEK(U+14)-1:GOSUB2380:GOTO3700
3690 I1=3:IFPEEK(U+13)<=0GOTO4190
3691 POKEU+13,PEEK(U+13)-1:GOSUB2370
3700 ONKFGOTO3710,3740,3720,3750
3710 LY=YL+3:UY=YM-3:S=1:GOTO3730
3720 LY=YL-3:UY=YM+3:S=-1
3730 X=XL:FORY=LYTOUYSTEPS:I=2*(X+V1-XB):J=YB-Y-W2:SET(C*I,J*Z,4):RESET(C*I,J*Z):X=X*1:NEXTY:GOTO3770
3740 LX=XL+3:UX=XM-3:S=1:GOTO3760
3750 LX=XL-3:UX=XM+3:S=-1
3760 Y=YL:FORX=LXTOUXSTEPS:I=2*(X+V1-XB):J=YB-Y-W2:SET(C*I,J*Z,4):RESET(C*I,J*Z):Y=Y*1:NEXTX
3770 IFABS(X-XM)<I1ANDABS(Y-YM)<I1THENPRINT@184,"THWUNK!";:SOUND150,1:AK=RND(7)+KM:GOTO3650
3771 PRINT@184,"SSWHT!";:GOTO4190
3780 K=KR+KF*Q-Q:IFPEEK(NT+K)=2THEN3785
3781 GOTO4190
3785 IFP(KF)>PEEK(D1+K)ANDP(KF)<PEEK(D2+K)THENIFABS(P(KF-1)-S(KF))<6THENPOKENT+K,1:IJ=0:ONKFGOSUB3850,3820,3870,3840:GOTO3800
3790 GOTO4190
3800 LR=PEEK(NO+K):NS=KF+1:IFNS>3THENNS=NS-4
3810 POKENT+LR+NS*Q,1:NS=5:GOSUB3020:GOTO4190
3820 A=V2-XB-2
3830 I1=3+IJ:B=YB-W2-PEEK(D2+K):L=PEEK(D2+K)-PEEK(D1+K):GOSUB2530:RETURN
3840 A=V1-XB:GOTO3830
3850 B=YB-W1
3860 I1=1+IJ/2:A=V1-XB+PEEK(D1+K):L=2*(PEEK(D2+K)-PEEK(D1+K)):GOSUB2610:RETURN
3870 B=YB-W2-2:GOTO3860
3880 K=KR+(KF-1)*Q:IFPEEK(K+NT)=3ANDRND(40)<20+PEEK(U+21)THEN3885
3881 PRINT@152,"NOTHING";:GOTO4190
3885 POKEK+NT,2:RF(KF-1)=1:PRINT@152,BL$"A DOOR!";:IJ=-2:LR=KR
3886 ONKFGOSUB3850,3820,3870,3840:GOTO4190
3900 N=PEEK(TR+KR):PRINT@152,BL$;:IFN=0ORXL-PEEK(XR+KR)>3ORYL-PEEK(YR+KR)>3THENPRINT@152,"CAN'T";:GOTO4190
3901 POKETR+KR,0:PRINT@152,"T#:"N;:POKEV+N-81,PEEK(V+N-81)+1:WC=WC+PEEK(TW+N):PRINT@120,"WT:"WC;:IN=0
3910 GOSUB2890:I=PEEK(TS+N):IFI>100THENJ=U+I-81:POKEJ,PEEK(J)+1:J=V+I-197:POKEJ,PEEK(J)+1:GOTO4190
3911 ONI+1GOTO4190,3930,3940,3950,3980,3990,4000,3920,4010,4020,4030,4630
3920 POKEV-89,1:GOTO4190
3930 J=RND(6):PRINT@472,J;"ITEMS";:POKEU+6,PEEK(U+6)+J:GOTO4190
3940 PS=4:SP=SP+1:GOTO4190
3950 PRINT@472,"A SWORD!";:PRINT@504,"USE IT?";:GOSUB2800:IFL=0GOTO3950
3951 PRINT@472,BL$;:PRINT@504,"";:IFC$="Y"THEN3955
3952 GOTO3960
3955 PB=PB+SM:SM=RND(4)+RND(4)-4:PB=PB-SM:WM=AS*(7+SM)+C
3956 IFSM>0THENSM=SM-INT(2-PEEK(V)/2):IFSM>1THENPRINT@472,"IT GLOWS";
3960 IFC$<>"Y"THENPOKEV+N-81,PEEK(V+N-81)-1:WC=WC-PEEK(TW+N):PRINT@472,BL$;
3970 GOTO4190
3980 J=RND(20):GOSUB2340:POKEU+13,PEEK(U+13)+J:GOSUB2370:GOTO4190
3990 J=RND(10):GOSUB2340:POKEU+14,PEEK(U+14)+J:GOSUB2380:GOTO4190
4000 POKEV-90,1:PA=PA+1:GOTO4190
4010 POKEV-88,1:GOTO4190
4020 POKEV-87,1:GOTO4190
4030 PW=75:POKEV+2235,PW:GOTO4190
4040 PRINT@472,BL$"DROP?";
4050 GOSUB2360:JJ=10*J:GOSUB2360:JJ=JJ+J:IFJJ<21THEN4055
4051 GOTO4060
4055 I=PEEK(V+JJ-81):IFI>0THEN4058
4057 GOTO4060
4058 POKEV+JJ-81,I-1:WC=WC-PEEK(TW+JJ):PRINT@472,BL$;:PRINT@120,"WT:"WC;
4059 IFPEEK(TR+KR)=0THENPOKETR+KR,JJ:POKEXR+KR,XL:POKEYR+KR,YL:GOSUB2890
4060 PRINT@472,BL$;:GOTO4190
4070 IFRND(100)<.3*(PEEK(U+20)+PEEK(U+22))*PEEK(UI+MQ)THENIN=1:GOTO4080
4071 GOTO4190
4080 PRINT@152,BL$"PASS BY";:GOTO4190
4090 IFPEEK(U+11)>0THENPOKEU+11,PEEK(U+11)-1:J=0:GOTO4100
4091 GOTO4130
4100 PC=PC+1+J:IFPC>PHTHENPC=PH
4110 PRINT@472,BL$;:PRINT@56,"WD:"INT(100*PC/PH+C);:GOTO4190
4120 I=U+6:IFPEEK(I)>0THENPOKEI,PEEK(I)-1:J=RND(6)+1:GOTO4100
4130 PRINT@472,"NO MORE ";:GOTO3290
4140 JJ=PEEK(U+21):PRINT@152,BL$;:I=PEEK(NO+KR+Q*KF-Q):MQ=PEEK(MT+I)
4141 IFI=0ORPEEK(MN+I)=0ORRND(1000)>JJ*JJ+PEEK(V-89)*700THENPRINT@152,"NOTHING";:GOTO4190
4150 GOSUB2981:PRINT@152,A$;:GOTO4190
4160 IFPEEK(NP+KR)>0ANDRND(20)<PEEK(U+21)THENGOSUB2870:GOTO4190
4161 PRINT@152,BL$"NOTHING";:GOTO4190
4180 K=1:GOSUB2830
4190 GOSUB2850:IFNB>0GOTO4210
4191 GOSUB3250:IFNB=0GOTO3290
4200 PRINT@344,"APPEARS":PRINT@312,BL$A$;:GOSUB2700:GOTO3290
4210 PRINT@216,BL$;:IFIN>0ORHI>0GOTO4470
4220 IFABS(X0-XM)>5ORABS(Y0-YM)>5GOTO4350
4230 IM=MA
4240 IM=IM-1:IFIM<0GOTO4300
4250 P=PA-ZD(IA):R=RND(20)+ML:IFR<PTHENPRINT@216,BL$"MISSED";:IM=IM*1:GOTO4240
4260 GOSUB2350:IFRND(20)-1<PEEK(U+4)THENPRINT@216,BL$"SHIELDED";:K=-PS:GOTO4270
4261 PRINT@216,BL$"HIT THEE";:K=0
4262 IFPEEK(US+MQ)=2ANDRND(20)>PEEK(U+21)/2+PEEK(V-81)ANDPEEK(V-88)=0THENGOSUB2300:PRINT@216,BL$"A CHILL";
4270 K=K+(MD*(R-P))/10-AA-PEEK(U+16):IFK<0THENK=0
4280 PC=PC-K:IFPC<1THENFORI=1TO1000:NEXTI:GOTO4580
4290 PRINT@56,"WD:"INT(100*PC/PH+C);:IFNB>0GOTO4240
4291 GOTO3290
4300 IFNB=0GOTO3290
4301 GOSUB2730:L=2:ONRND(4)GOTO4310,4320,4330,4340
4310 YM=YM+L:GOTO4460
4320 XM=XM+L:GOTO4460
4330 YM=YM-L:GOTO4460
4340 XM=XM-L:GOTO4460
4350 GOSUB2730:GOSUB2880:A=XL-XM:B=YL-YM:IFABS(A)<ABS(B)GOTO4370
4351 IFA>0THENMF=2:GOTO4380
4352 MF=4:GOTO4380
4370 IFB>0THENMF=1:GOTO4380
4371 MF=3
4380 L=MS:ONMFGOTO4390,4410,4430,4450
4390 IFYM+L>YL-3THENYM=YL-3:GOTO4460
4391 YM=YM+L:GOTO4460
4410 IFXM+L>XL-3THENXM=XL-3:GOTO4460
4411 XM=XM+L:GOTO4460
4430 IFYM-L<YL+3THENYM=YL+3:GOTO4460
4431 YM=YM-L:GOTO4460
4450 IFXM-L<XL+3THENXM=XL+3:GOTO4460
4451 XM=XM-L
4460 GOSUB2310:GOSUB2700
4470 IFMP<1ANDNB>0THEN4475
4471 GOTO4480
4475 GOSUB2730:GOSUB2780:EX=EX+20*ML*ML+15:KC=KC+1:PRINT@408,KC;:PRINT@152,BL$"VICTORY!";:GOSUB2650
4476 M=PEEK(MN+KR):IFM>0THENPOKEMN+KR,M-1:IFM>1THENGOSUB3180:PRINT@152,"ANOTHER!";:GOSUB2700
4480 IFMP<1THENNB=0:PRINT@184,BL$;:PRINT@216,BL$;:PRINT@312,BL$;:PRINT@344,BL$;
4490 GOTO3290
4500 CLS:PRINT"THOU LEAVEST THE DUNJON"
4510 PRINT"EXPERIENCE:"EX:INPUT"DOST WISH TO REENTER";C$:IFLEFT$(C$,1)="Y"THEN4515
4511 GOTO4520
4515 WC=PEEK(U+12):KR=1:PC=PH:XA=PEEK(V+2236):YA=PEEK(V+2237):KF=PEEK(V+2238):TA=100:GOSUB2390:GOTO3270
4520 INPUT"WISH THOU TO SAVE THE DUNJON";A$:IFLEFT$(A$,1)<>"Y"GOTO4630
4530 D(498)=EX:IFSM<0THENSM=0
4540 POKEU+10,SM
4550 INPUT"ENTER DUNGEON NAME";A$:INPUT"PRESS play & record";C$:SAVE*D,LEFT$(A$,8):PRINT"LEVEL SAVED":GOTO4630
4580 CLS:PRINT@233,"THOU ART SLAIN!":FORI=1TO2500:NEXTI:CLS:I=SQR(RND(16))+.7:ONIGOTO4590,4610,4620,4600
4590 PRINT"THOU ART EATEN":POKEU-12,0:GOTO4630
4600 PRINT"BENEDIC THE CLERIC FOUND THEE":GOTO4510
4610 PRINT"LOWENTHAL THE MAGE FOUND THEE":FORI=81TO90:POKEV-I,0:NEXTI:GOTO4510
4620 PRINT"OLIAS THE DWARF FOUND THEE":FORI=61TO90:POKEV-I,0:NEXTI
4621 SM=0:POKEU+10,0:POKEU+16,0:POKEU+14,0:POKEU+6,0:GOTO4510
4630 PRINT"LOAD NOW THE INNKEEPER":END
